package com.yanqu.road.server.cmd.activity.seacraftsouthsea;

import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.pb.activity.SeacraftSouthSeaProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.seacraft.SeacraftSouthSeaModule;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @Description
 * @Author cwq
 * @Data 2022/1/20 15:28
 */
@Cmd(code = GameProtocol.S_SEACRAFT_SOUTH_SEA_RECEIVE_WIN_STREAK_REWARD_FROM_CROSS, desc = "海上争霸 南海丝路 领取连胜奖励 跨服返回区服 协议")
public class SeacraftSouthSeaReceiveWinStreakRewardFromCrossCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        SeacraftSouthSeaProto.SeacraftSouthSeaReceiveWinStreakRewardRespMsg reqMsg = SeacraftSouthSeaProto.SeacraftSouthSeaReceiveWinStreakRewardRespMsg.parseFrom(packet.getBytes());
        if(reqMsg.getRet() == 0){
            // 加奖励
            player.getModule(CurrencyModule.class).addCurrency(reqMsg.getReward(), eLogMoneyType.SeacraftActivity, eLogMoneyType.SeacraftActivityWinStreakReward);
            // 对决奖励
            player.getModule(SeacraftSouthSeaModule.class).battleEnd(reqMsg.getResult());
        }
        player.sendPacket(ClientProtocol.U_SEACRAFT_SOUTH_SEA_RECEIVE_WIN_STREAK_REWARD, reqMsg.toBuilder());
    }

    @Override
    public void sendData(GamePlayer player) {
    }
}
